<template>
	<view class="container">
		<!-- <view class="title px-50">服务</view> -->
		<view class="service-list">
			<block v-for="item in list" :key="item.id">
				<view style="height: 18rpx; background-color: #9cbce3"></view>
				<view class="service p-50">
					<view class="title">{{ item.title }}</view>
					<view class="hr"></view>
					<view class="content">
						<rich-text :nodes="$tools.formatRichText(item.content)"></rich-text>
					</view>
				</view>
			</block>
		</view>
	</view>
</template>

<script>
import { getServiceList } from '@/api/index';
export default {
	data() {
		return {
			query: {
				page: 1,
				limit: 10,
			},
			list: [],
			all: false,
		};
	},
	onShareAppMessage() {},
	onShareTimeline() {},
	onLoad() {
		this.getInit();

		this.query.page = 1;
		this.list = [];
		this.all = false;
		this.getData();
	},
	onShow() {},
	onReachBottom() {
		if (this.all == true) {
			this.$tools.toast('已加载全部数据...');
			return false;
		}
		this.query.page++;
		this.getData();
	},
	onPullDownRefresh() {
		this.query.page = 1;
		this.list = [];
		this.all = false;
		this.getData();
	},
	methods: {
		getInit() {},
		getData() {
			getServiceList(this.query).then((res) => {
				console.log(res);
				const list = res.data.data;
				this.list = this.list.concat(list);
				if (this.query.page == res.data.last_page) {
					this.all = true;
				}
				uni.stopPullDownRefresh();
			});
		},
	},
};
</script>

<style lang="scss">
@import 'index.scss';
</style>
